<%@ include file="includes/include.jsp" %>

<c:import url="includes/header.jsp">
  <c:param name="pageTitle" value="${model.chapter.name}"/>
</c:import>

<style type="text/css">
  a, h2 {
    color: #ff0e0e
  }
</style>

<script type="text/javascript">
  function expandDescription(anchor, divId) {
    var parent = anchor.parentNode;
    parent.removeChild(anchor);

    var div = document.getElementById(divId);
    div.style.display = 'block';
  }

  window.onload = function() {
    tabberAutomatic();

    // Show "Events" tab by default if t=events is in URL
    if (window.location.toString().indexOf('t=events') != -1) {
      document.getElementById('mainTabs').tabber.tabShow(1);
    }
  }
</script>

<div id="title">
  <h2><c:out value="${model.chapter.name}"/></h2>
  <h5>
    <c:if test="${model.chapter.city != ''}">
      <c:out value="${model.chapter.city}"/>,
    </c:if>
    <c:if test="${model.chapter.state != ''}">
      <c:out value="${model.chapter.state}"/>,
    </c:if>
    <c:out value="${model.chapter.country}"/>
  </h5>
</div>

<div style="position:relative">
  <div class="sidebar-extension"></div>
</div>
<div>
  <div style="float:left; width:715px">
    <div class="tabber" id="mainTabs">
      <div class="tabbertab" title="Overview">
        <div style="margin-top:10px;">
          <div class="text">
            <c:out value="${model.chapter.description}" escapeXml="false"/>
          </div>
          <c:if test="${not empty model.events}">
            <div style="background-color:#f6f6f6; border:solid silver 1px; padding:10px">
              <h5 style="color:#444">Next event:</h5>
              <h4 style="margin-bottom:15px; margin-top:1px">
                <c:out value="${model.events[0].name}"/>
              </h4>

              <table style="width:100%">
                <tr>
                  <td style="padding-right:15px; width:150px" valign="top">
                    <div style="background-color:#ff0e0e; padding:5px 5px 0 5px">
                      <div style="color:white; float:left; font-size:10pt; width:auto">
                        <fmt:formatDate pattern="EEEE" value="${model.events[0].startDate}"/>
                      </div>
                      <div style="color:white; float:right; font-size:10pt; font-weight:bold; width:auto">
                        <fmt:formatDate pattern="yyyy" value="${model.events[0].startDate}"/>
                      </div>
                      <br style="clear:both"/>
                    </div>
                    <div style="border:solid #ff0e0e 2px; background-color:white; padding:3px 0; text-align:center">
                      <div style="font-size:13pt; font-weight:bold">
                        <fmt:formatDate pattern="MMMM" value="${model.events[0].startDate}"/>
                      </div>
                      <div style="font-size:24pt; font-weight:bold; margin-top:-3px">
                        <fmt:formatDate pattern="d" value="${model.events[0].startDate}"/>
                      </div>
                      <div style="color:#333; font-size:11pt; margin-top:5px">
                        <fmt:formatDate pattern="h:mm a" value="${model.events[0].startDate}"/>
                      </div>
                    </div>
                  </td>
                  <td style="font-size:11pt; padding-right:15px; width:275px">
                    <span style="font-size:10pt; font-weight:bold">Location:</span>
                    <br/>
                    <c:out value="${model.events[0].streetAddress}"/><br/>
                    <c:if test="${not empty model.events[0].room}">
                      <c:out value="${model.events[0].room}"/><br/>
                    </c:if>
                    <c:choose>
                      <c:when test="${not empty model.events[0].state}">
                        <c:out value="${model.events[0].city}"/>, <c:out value="${model.events[0].state}"/>
                      </c:when>
                      <c:otherwise>
                        <c:out value="${model.events[0].city}"/>
                      </c:otherwise>
                    </c:choose>
                    <br/>
                    <c:choose>
                      <c:when test="${not empty model.events[0].state}">
                        <a href="http://maps.google.com/maps?q=<c:out value="${model.events[0].streetAddress}"/>+<c:out value="${model.events[0].city}"/>+<c:out value="${model.events[0].state}"/>">Map it</a>
                      </c:when>
                      <c:otherwise>
                        <a href="http://maps.google.com/maps?q=<c:out value="${model.events[0].streetAddress}"/>+<c:out value="${model.events[0].city}"/>">Map it</a>
                      </c:otherwise>
                    </c:choose>
                  </td>
                  <td>
                    <c:if test="${not empty model.events[0].url}">
                      <div style="font-size:18pt">
                        <b>&rarr;</b> <a href="<c:out value="${model.events[0].url}"/>" class="fancy">More details</a>
                      </div>
                    </c:if>
                  </td>
                </tr>
              </table>
              <div style="font-size:13px; margin-top:10px; text-align:center">
                <a href="javascript:none" onclick="expandDescription(this, 'gtugsorg-chapter-upcoming_event_description')">Show description</a>
              </div>
              <div class="smalltext" id="gtugsorg-chapter-upcoming_event_description" style="background-color:#f6f6f6; border-top:solid silver 1px; display:none; margin-top:10px; padding:10px 5px 0 5px;">
                <c:out value="${model.events[0].description}" escapeXml="false"/>
              </div>
            </div>
          </c:if>
        </div>
      </div>
      <div class="tabbertab" title="Past events">
        <div style="margin-top:10px;">
          <table cellpadding="0" cellspacing="0" style="width:100%;">
            <c:forEach items="${model.pastevents}" var="event" varStatus="eventRow">
              <tr>
                <td style="padding-bottom:25px; width:65px; vertical-align:top">
                  <div style="width:50px">
                    <div style="background-color:#ff0e0e; color:white; padding:2px 0 0 2px">
                      <div style="font-size:11px; text-align:center">
                        <fmt:formatDate pattern="yyyy" value="${event.startDate}"/>
                      </div>
                    </div>
                    <div style="border:solid #ff0e0e 2px; background-color:white; padding:2px 0; text-align:center">
                      <div style="font-size:12px; font-weight:bold">
                        <fmt:formatDate pattern="MMM" value="${event.startDate}"/>
                      </div>
                      <div style="font-size:18px; font-weight:bold; margin-top:-3px">
                        <fmt:formatDate pattern="d" value="${event.startDate}"/>
                      </div>
                    </div>
                  </div>
                </td>
                <td style="padding-bottom:25px; vertical-align:top">
                  <div style="font-size:16px; font-weight:bold;">
                    <c:out value="${event.name}"/>
                  </div>
                  <div style="color:#333; font-size:14px">
                    <div>
                      <c:forEach items="${event.topics}" var="topic" varStatus="topicRow">
                        <c:choose>
                          <c:when test="${topicRow.last}">
                            <em><c:out value="${topic}"/></em>
                          </c:when>
                          <c:otherwise>
                            <em><c:out value="${topic}"/></em>,
                          </c:otherwise>
                        </c:choose>
                      </c:forEach>
                    </div>
                    <c:if test="${!empty event.attendeeCount}">
                      <div>
                        <c:out value="${event.attendeeCount}"/> attendees
                      </div>
                    </c:if>
                    <div>
                      <a href="javascript:none" onclick="expandDescription(this, 'gtugsorg-chapter-event_description_<c:out value="${eventRow.index}"/>')">more...</a>
                    </div>
                  </div>
                  <div class="smalltext" id="gtugsorg-chapter-event_description_<c:out value="${eventRow.index}"/>" style="background-color:#f6f6f6; border:solid silver 1px; margin-top:10px; padding:10px; display:none;">
                    <c:out value="${event.description}" escapeXml="false"/>
                  </div>
                </td>
              </tr>
            </c:forEach>
          </table>
        </div>
      </div>
    </div>
  </div>
  <div class="sidebar">
    <img src="http://maps.google.com/staticmap?center=<c:out value="${model.chapter.latitude}"/>,<c:out value="${model.chapter.longitude}"/>&zoom=11&size=200x124&maptype=terrain&markers=<c:out value="${model.chapter.latitude}"/>,<c:out value="${model.chapter.longitude}"/>,red&key=ABQIAAAAVcC1CwycXgD607vgA6-JWRQsQrdbh9VYytIyhTexABq-UD140xRDqWhEuEAiRVhjGXFCXv8ybo6Mfw&sensor=false"/>
    <div style="font-size:11pt; margin:15px 0px">
      <c:if test="${model.chapter.website ne ''}">
        <a href="<c:out value="${model.chapter.website}"/>">Website</a>
      </c:if>
      <c:if test="${model.chapter.mailingList ne ''}">
        <a href="<c:out value="${model.chapter.mailingList}"/>">Mailing list</a>
      </c:if>
    </div>
    <dl>
      <dt>Organizers:</dt>
      <dd>
        <ul>
          <c:forEach items="${model.chapter.administrators}" var="administrator">
            <li><a href="mailto:<c:out value="${administrator.email}"/>"><c:out value="${administrator.name}"/></a></li>
          </c:forEach>
        </ul>
      </dd>
    </dl>
    <hr/>
    <div style="font-size:13px;line-height:1.8em">
    <div><strong>Status:</strong> <c:out value="${model.chapter.status}"/></div>
    <div><strong>Number of events:</strong> <c:out value="${model.chapter.numEvents}"/></div>
    <c:if test="${!empty model.chapter.averageAttendees}">
      <div><strong>Average attendees:</strong> <c:out value="${model.chapter.averageAttendees}"/></div>
    </c:if>
    </div>
  </div>
</div>
<br style="clear:both"/>

<%@ include file="includes/footer.jsp" %>